#include <iostream>
#include <mutex>
#include <thread>

int account = 0;
std::mutex mut;
std::mutex mut2;

void inc() {
  for (int i = 0; i < 50; ++i) {
    {
      std::lock_guard<std::mutex> guard(mut);
      ++account;
    }
  }
}

void dec() {
  for (int i = 0; i < 50; ++i) {
    {
      std::lock_guard<std::mutex> guard(mut);
      --account;
    }
  }
}

int main(int argc, char *argv[]) {
  std::lock(mut, mut2);
  std::thread thisthread(inc);
  std::thread thatthread(dec);
  thisthread.join();
  thatthread.join();
  if (account != 0) {
    std::cout << "not 0 " << account << std::endl;
  }
  return 0;
}
